#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project : gtmsAutoTestProject 
@File    : pay_api.py
@IDE     : PyCharm 
@Author  : Mario
@Date    : 2022/4/26 16:01 
@Describe: POS支付相关接口
"""
from APIs.posApi.base_pos_api import BasePosApi


class PayApi(BasePosApi):

    def __init__(self, brandCode, environment):
        super().__init__(brandCode, environment)

    def pay_type_list(self):
        """
        获取门店支付方式
        :return:
        """
        payload = '{}'
        response = self.http_requests('pay/type/list', payload)
        return response

    def order_pay_detail(self, orderNo):
        """
        订单支付详情
        :param orderNo: 订单号
        :return:
        """
        payload = '{"orderNo": "' + orderNo + '"}'
        response = self.http_requests('pay/common/order-pay/detail', payload)
        return response

    def cash_pay(self, orderNo, payAmount, payModeId):
        """
        现金支付
        :param orderNo:订单号
        :param payAmount:支付金额
        :param payModeId:支付方式
        :return:
        """
        payload = '{"orderNo":"' + orderNo + '","payAmount":"' + payAmount + '","payModeId":"' + payModeId + '"}'
        response = self.http_requests('pay/cash/pay', payload)
        return response

    def confirm_checkout(self, orderNo):
        """
        确认结台
        :param orderNo: 订单号
        :return:
        """
        payload = '{"orderNo":"' + orderNo + '"}'
        response = self.http_requests('order/settlement/confirm-checkout', payload)
        return response

    def pay_common_refund(self, orderNo, refundAmount, payNo):
        """
        支付退款
        :param orderNo: 订单号
        :param refundAmount: 退款金额
        :param payNo: 支付号(商户订单号)
        :return:
        """
        payload = '{"orderNo":"' + orderNo + '","refundAmount":"' + refundAmount + '","payNo":"' + payNo + '"}'
        response = self.http_requests('pay/common/refund', payload)
        return response

    def pay_xinMeiDa_cancel(self, orderNo, payNo):
        """
        取消新美大支付
        :param orderNo: 订单号
        :param payNo: 支付号(商户订单号)
        :return:
        """
        payload = '{"orderNo":"' + orderNo + '","payNo":"' + payNo + '"}'
        response = self.http_requests('pay/xinmeida/cancel', payload)
        return response

    def order_pay(self, orderNo):
        """
        订单结账
        :param orderNo: 订单号
        :return:
        """
        payload = '{"orderNo":"' + orderNo + '"}'
        response = self.http_requests('order/pay', payload)
        return response


if __name__ == '__main__':
    test = PayApi("823882", "sit")
    test.order_pay("1010000284774")
